package cn.com.elite;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HTPayService1 extends HttpServlet{
	private static final Log log=LogFactory.getLog(HTPayService1.class);
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException{
		String poacode=request.getParameter("poacode");
	    log.info("poacode:"+poacode);
		String merOrderNo=request.getParameter("merOrderNo");
	    log.info("merOrderNo:"+merOrderNo);
	    String type=request.getParameter("type");
	    log.info("type:"+type);
	    String COM_CODE=HTPayService.ebean.chaxunString(" select HTPay_Getagency('"+merOrderNo+"') from dual");
		log.info("COM_CODE:"+COM_CODE);
		String response_message="";
	    if(type.equals("CX")){
	    	HTPayService.getJyCxProcess(merOrderNo,"",COM_CODE,HTPayService.USER,HTPayService.PASSWORD);
	    	response_message=HTPayService.ebean.chaxunString("select distinct trans_message from HTPAY_CANCELINFO_DTO where poacode='"+poacode+"'");
	    }else if(type.equals("CG")){
	    	HTPayService.getJyCgProcess(merOrderNo,"",COM_CODE,HTPayService.USER,HTPayService.PASSWORD);
	    	response_message=HTPayService.ebean.chaxunString("select distinct trans_message from HTPAY_PAY_INFO_DTO where poacode='"+poacode+"'");
	    }
	    log.info("response_message:"+response_message);
	    request.setCharacterEncoding("UTF-8");
	    response.setContentType("text/html;charset=utf-8;");
	    PrintWriter out=response.getWriter();
	    out.print(response_message);
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException{
		this.doPost(request, response);
	}
}
